import { IPSAppDELogicLink } from '../../app/dataentity/ipsapp-delogic-link';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicLink } from './ipsdelogic-link';
import { IPSDELogicLinkGroupCond } from './ipsdelogic-link-group-cond';
import { IPSDELogicNode } from './ipsdelogic-node';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicLinkImpl extends PSModelObjectImpl implements IPSDELogicLink, IPSAppDELogicLink {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdelogicnode: IPSDELogicNode | null = null;

  getDstPSDELogicNode(): IPSDELogicNode | null {
    if (this.dstpsdelogicnode != null) return this.dstpsdelogicnode;
    const value = this.M.getDstPSDELogicNode;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicnode = ipsdelogic.findPSDELogicNode(value);
    }
    return this.dstpsdelogicnode;
  }

  get dstPSDELogicNode(): IPSDELogicNode | null {
    return this.getDstPSDELogicNode();
  }

  getDstPSDELogicNodeMust(): IPSDELogicNode {
    const value = this.getDstPSDELogicNode();
    if (value == null) {
      throw new Error('未指定目标逻辑节点对象');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdelogiclinkgroupcond: IPSDELogicLinkGroupCond | null = null;

  getPSDELogicLinkGroupCond(): IPSDELogicLinkGroupCond | null {
    if (this.psdelogiclinkgroupcond != null) return this.psdelogiclinkgroupcond;
    const value = this.M.getPSDELogicLinkGroupCond;
    if (value == null) {
      return null;
    }
    this.psdelogiclinkgroupcond = this.getPSModel4('dataentity.logic.IPSDELogicLinkGroupCond', value, 'getPSDELogicLinkGroupCond') as IPSDELogicLinkGroupCond;
    return this.psdelogiclinkgroupcond;
  }

  get psDELogicLinkGroupCond(): IPSDELogicLinkGroupCond | null {
    return this.getPSDELogicLinkGroupCond();
  }

  getPSDELogicLinkGroupCondMust(): IPSDELogicLinkGroupCond {
    const value = this.getPSDELogicLinkGroupCond();
    if (value == null) {
      throw new Error('未指定连接条件对象');
    }
    return value;
  }

  protected srcpsdelogicnode: IPSDELogicNode | null = null;

  getSrcPSDELogicNode(): IPSDELogicNode | null {
    if (this.srcpsdelogicnode != null) return this.srcpsdelogicnode;
    const value = this.M.getSrcPSDELogicNode;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.srcpsdelogicnode = ipsdelogic.findPSDELogicNode(value);
    }
    return this.srcpsdelogicnode;
  }

  get srcPSDELogicNode(): IPSDELogicNode | null {
    return this.getSrcPSDELogicNode();
  }

  getSrcPSDELogicNodeMust(): IPSDELogicNode {
    const value = this.getSrcPSDELogicNode();
    if (value == null) {
      throw new Error('未指定源逻辑节点对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get catchLink(): boolean {
    return this.M.catchLink != null ? this.M.catchLink : false;
  }

  get defaultLink(): boolean {
    return this.M.defaultLink != null ? this.M.defaultLink : false;
  }

  get subCallLink(): boolean {
    return this.M.subCallLink != null ? this.M.subCallLink : false;
  }

  get cls(): string {
    return 'PSDELogicLinkImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDELogicLink' || cls == 'dataentity.logic.IPSDELogicLink') return true;
    return super.instanceof(cls);
  }
}
